package sunday.service.lmp.manager;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import org.apache.poi.hssf.usermodel.HSSFCell;
import org.apache.poi.hssf.usermodel.HSSFRow;
import org.apache.poi.hssf.usermodel.HSSFSheet;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.multipart.MultipartFile;
import sunday.mapper.manager.ManagerMapper;
import sunday.pojo.manager.Manager;
import sunday.pojo.school.*;
import sunday.pojo.teacher.Teacher;
import sunday.service.manager.ManagerService;

import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;

/**
 * Created by yang on 2017/5/15.
 * At 15:49
 */
@Service("managerService")
public class ManagerServiceImpl implements ManagerService {

    @javax.annotation.Resource(name = "managerMapper")
    private ManagerMapper managerMapper;

    @Override
    @Transactional
    public int insert(Manager manager) {
        return managerMapper.insert(manager);
    }

    @Override
    public boolean delSpecialty(Specialty specialty) {
        if(specialty.getSpecialtyId()==null){
            return false;
        }
        managerMapper.delSpecialty(specialty);
        return true;
    }

    @Override
    public List<Manager> select(Page page, Map<String, Object> params) {
        if (null != page) {
            PageHelper.startPage(page.getPageNum(), page.getPageSize(), page.getOrderBy());
        }
        List<Manager> managers = managerMapper.select(params);
        if (null != managers && managers.size() > 0) {
            return managers;
        }
        return null;
    }

    @Override
    public List<SpeWithStu> selectSpecialty(SpeQuestion question) {

        List<SpeWithStu> specialties = managerMapper.selectSpecialty(question);
        if (null != specialties && specialties.size() > 0) {
            return specialties;
        }
        return null;
    }

    @Override
    public List<Specialty> getSpe(Specialty specialty) {
        List<Specialty> specialties=managerMapper.getSpe(specialty);
        return specialties;
    }

    @Override
    public void saveStudent(Student student) {
        managerMapper.saveStudent(student);
    }

    @Override
    public List<Student> selectStudent(Student student) {
        List<Student> students=managerMapper.selectStudent(student);
        return students;
    }

    @Override
    public void updateStudent(Student student) {
        managerMapper.updateStudent(student);
    }

    @Override
    public List<Course> selectCourse(Course course) {

        return managerMapper.selectCourse(course);
    }

    @Override
    public void delStu(Student student) {
        managerMapper.delStu(student);
    }

    @Override
    public void saveCourse(Course course) {
        managerMapper.saveCourse(course);
    }

    @Override
    public void delCou(Course course) {
        managerMapper.delCou(course);
    }

    @Override
    public void updateCourse(Course course) {
        managerMapper.updateCourse(course);
    }

    @Override
    public List<Teacher> selectTeacher(Teacher teacher) {
        return managerMapper.selectTeacher(teacher);
    }

    @Override
    public void saveTeacher(Teacher teacher) {
        managerMapper.saveTeacher(teacher);
    }

    @Override
    public void updateTeacher(Teacher teacher) {
        managerMapper.updateTeacher(teacher);
    }

    @Override
    public void delTeacher(Teacher teacher) {
        managerMapper.delTeacher(teacher);
    }

    @Override
    public int insertSpeBatch(List<Specialty> list) {
        return managerMapper.insertSpeBatch(list);
    }

    @Override
    public int addSpecialty(Specialty specialty) {
        int n=managerMapper.addSpecialty(specialty);
        return n;
    }


}
